package com.chocho.javacompileserver.handler;

import com.chocho.javacompileserver.exception.CompileException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * 统一异常拦截
 * Created by chocho on 2022/3/16.
 */
@ControllerAdvice
@ResponseBody
public class MyExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(MyExceptionHandler.class);

    /**
     * 拦截编译异常
     * @param e
     * @return
     */
//    @ExceptionHandler(value = Exception.class)
//    @ResponseStatus
//    public Msg exceptionHandler(Exception e){
//        logger.info(e.getMessage());
//        Msg msg = new Msg();
//        msg.setCode("500");
//        msg.setMsg("compile-error");
//        return msg.add("detailMsg", e.getMessage());
//    }
}
